function [Sh] = detnoisepsd(detName,f)
% 
% DETNOISEPSD - return the one-sided PSD of a detector
% 
% usage: [Sh] = detnoisepsd(detName,f)
% 
%   f       - a vector of frequencies at which the PSD is computed
%   detName - name of the detector (LIGO/Virgo/AdvLIGO/AdvVirgo/EnhLIGO) 
%   Sh      - one sided PSD computed at f  
% 
% P. Ajith, 17.07.06
% 
% $Id: detnoisepsd.m 39 2009-08-08 21:17:28Z Ajith.Parameswaran $

negIdx = find(f < 0);
f(negIdx) = -f(negIdx);

if strcmp(detName,'LIGO1') | strcmp(detName,'LIGO')
   x  = f/150.;
   Sh = 9e-46*( (4.49*x).^-56 + 0.16*(x.^-4.52) + 0.52 + 0.32*x.^2 ); 
   
%     % lisa's parametrisation
%     seis =  3.3e-21*(30./f).^14;
%     thermal = 3.8e-23*(100./f).^2;
%     shot = 1.13e-23 * sqrt( 1 + (f./90).^2);
%     Sh = (seis.^2 + thermal.^2 + shot.^2);
    
   fLow = 40;
   idx = find(f < fLow);
   Sh(idx) = inf;

elseif strcmp(detName,'EnhLIGO') 
   x  = f/178.;
   Sh = 1.5e-46*(exp(-5.5*log(x).^2).*x.^-52.6*1.33e-27 + 0.16*(x.^-4.2) + 0.52 + 0.30*x.^2.1 ); 
   
   fLow = 40;
   idx = find(f < fLow);
   Sh(idx) = inf;

elseif strcmp(detName,'Virgo') | strcmp(detName,'VIRGO')
   x = f/500.;
   s0 = 10.2e-46;
   Sh = s0*(power(7.87.*x,-4.8) + 6./17./x + 1. + x.*x );

%     s0 = 3.24e-46;
%     Sh = s0*(power(6.23.*x,-5) + 2./x + 1. + x.*x );
   fLow = 20;
   idx = find(f < fLow);
   Sh(idx) = inf;

elseif strcmp(detName,'AdvLIGO') | strcmp(detName,'LIGO2')

    % PSD in LAL
     x = f/215;
     s0 = 1e-49;
     Sh = s0*(power(x,-4.14) - 5*x.^-2 + 111*(1-x.^2+x.^4/2)./(1+x.^2/2));

%    % PSD used in Will, 1995 paper (massive graviton)
%    x = f/70;
%    s0 = 3e-48;
%    Sh = s0*(x.^-4 + 2 + 2.*x.^2)./5;

   fLow = 10;
   idx = find(f < fLow);
   Sh(idx) = inf;

elseif strcmp(detName,'AdvVirgo') | strcmp(detName,'Virgo2')
    x = f/720;
    s0 = 1e-47;
    Sh = s0*(2.67e-7./power(x,5.60) + (0.59.*exp(power(log(x),2).*(-3.20+ ...
          (-1.08- 0.13.*log(x)).*log(x))))./power(x,4.1) + ...
          (0.68*power(x,5.34))./exp(0.73.*power(log(x),2)));

   fLow = 10;
   idx = find(f < fLow);
   Sh(idx) = inf;

elseif strcmp(detName,'WhiteNoise')
   Sh = ones(size(f));
else   
    error('### unknown detName');
end
